-
-
Notifications
You must be signed in to change notification settings - Fork 750
💥 Rename regex
to pattern
to provide compatibility with Pydantic V2
#1231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
regex
to param
to provide compatibility with Pydantic V2
Thanks for the PR! We're going through the backlog of PRs right now, and will get back to you once we've had the time to review this and consider the (breaking) change 🙏 |
@svlandeg Nice to hear you are taking action on this matter. There is remark, the parameter the was renamed between Pydantic v1 and v2 is The suggestion I made in the PR was to keep both versions compatible when upgrading, but there is an alternative, which is not managing the change between them and just provide the proper type hints. If you want me to update the PR just let me know, IDK which approach is more adequate for the project. |
@stickM4N, could you please clarify why this should be treated as breaking change? Apart from that, should we add a test for new parameter? |
regex
to param
to provide compatibility with Pydantic V2regex
to pattern
to provide compatibility with Pydantic V2
Hi @YuriiMotov, nice to hear from you again. from sqlmodel import SQLModel, Field
class MyClass(SQLModel):
id: str = Field(unique=True, pattern=r"^\d{5}$") This code raises I have other proposition that is more comfortable to work with in my opinion, but its more of a change... and its to convert |
I faced this issue with Pydantic V2 and there is a simple workaround to it by passing the
pattern
Field parameter as schema extra:Ex:
This should be labeled as breaking
I don't know if this issue was already fixed in another branch, I saw there was a temporary PR already made but closed.